package com.ctbri.vSearch.util;


import com.ctbri.vSearch.bean.po.ArticleItem;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by xuexi on 2017/5/3.
 */
public class CountScore {
    public static void countScore(Date date, Map<ArticleItem,Double> articleScore,Map<ArticleItem, HashMap<String, Float>> termScore, ArticleItem ai,Float score,String word,Double weight){
        Date now = new Date();
        double dateInterval = Math.log((now.getTime() - date.getTime()) / (1000*3600*24));

        if(articleScore.keySet().contains(ai)) {
            articleScore.put(ai, articleScore.get(ai) + weight * score); //Int
            HashMap<String, Float> tmp = termScore.get(ai);
            tmp.put(word, score);
            termScore.put(ai, tmp);
        }
        else {
            articleScore.put(ai, weight*score -dateInterval);
            HashMap<String, Float> tmp = new HashMap<String, Float>();
            tmp.put(word, score);
            termScore.put(ai, tmp);
        }

    }

}
